Skip to content

fix : added input validation and XSS protection to review submission API route - #2

Open
tmdeveloper007 wants to merge 1 commit into
syedahmedkhaderi:mainfrom
tmdeveloper007:review-input-fix
Open

fix : added input validation and XSS protection to review submission API route#2
tmdeveloper007 wants to merge 1 commit into
syedahmedkhaderi:mainfrom
tmdeveloper007:review-input-fix

Conversation

@tmdeveloper007

Copy link
Copy Markdown

Closes (upstream issues disabled — no issue created).

Summary of What Has Been Done:
Added input validation and XSS protection to the send-review API route at app/api/send-review/route.js. Added required-field presence checks for name, email, and review, an email format validation using regex, rating range validation (must be integer 1-5), and an escapeHtml() helper to prevent XSS when rendering user input into HTML email content.

Changes Made:

  • app/api/send-review/route.js: add required-field validation, isValidEmail(), validateRating(), escapeHtml() for XSS protection
  • security-tests/send-review-input.test.cjs: new file covering all validation and sanitization logic

Impact it Made:

  • Prevents XSS/injection payloads from being embedded in outgoing review emails
  • Provides clear 400 error messages for invalid or missing fields
  • Validates rating is always within the 1-5 star range
  • Adds unit test coverage for all new validation functions

Note: Please assign this PR to the tmdeveloper007 account.

… route

- Add required-field validation for name, email, review
- Add isValidEmail() regex check for email field
- Add rating range validation (integer 1-5) before email is sent
- Add escapeHtml() to prevent XSS in HTML email body
- Add security tests in security-tests/send-review-input.test.cjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant